﻿using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

namespace YJKCopyModel
{
	public class ToleranceDic : Dictionary<string, double>, IXmlSerializable
	{
		public XmlSchema GetSchema()
		{
			return null;
		}

		public void ReadXml(XmlReader reader)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(string));
			XmlSerializer xmlSerializer2 = new XmlSerializer(typeof(double));
			bool isEmptyElement = reader.IsEmptyElement;
			reader.Read();
			bool flag = isEmptyElement;
			if (!flag)
			{
				while (reader.NodeType != XmlNodeType.EndElement)
				{
					reader.ReadStartElement("DicNode");
					reader.ReadStartElement("KeyNode");
					string key = (string)xmlSerializer.Deserialize(reader);
					reader.ReadEndElement();
					reader.ReadStartElement("ValueNode");
					double value = (double)xmlSerializer2.Deserialize(reader);
					reader.ReadEndElement();
					base.Add(key, value);
					reader.ReadEndElement();
					reader.MoveToContent();
				}
				reader.ReadEndElement();
			}
		}

		public void WriteXml(XmlWriter writer)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(string));
			XmlSerializer xmlSerializer2 = new XmlSerializer(typeof(double));
			foreach (string text in base.Keys)
			{
				writer.WriteStartElement("DicNode");
				writer.WriteStartElement("KeyNode");
				xmlSerializer.Serialize(writer, text);
				writer.WriteEndElement();
				writer.WriteStartElement("ValueNode");
				double num = base[text];
				xmlSerializer2.Serialize(writer, num);
				writer.WriteEndElement();
				writer.WriteEndElement();
			}
		}

		private const string m_useNodeName = "DicNode";

		private const string m_useKeyNodeName = "KeyNode";

		private const string m_useValueNodeName = "ValueNode";
	}
}
